package easy;

import java.util.Arrays;
import java.util.HashMap;

/**
 * 最高身高
 */
public class test7 {
    public static void main(String[] args) {
        test7 test7 = new test7();
        String[] strings = {"Mary", "John", "Emma"};
        int[] ints = {180, 165, 170};
        System.out.println(Arrays.toString(test7.sortPeople(strings, ints)));
    }

    public String[] sortPeople(String[] names, int[] heights) {
        HashMap<Integer, String> map = new HashMap<>();
        String[] s = new String[names.length];
        for (int i = 0; i < names.length; i++) {
            map.put(heights[i], names[i]);
        }
        Arrays.sort(heights);
        int size = map.size() -1;
        for (int i = 0; i < map.size(); i++) {
            s[size] = map.get(heights[i]);
            size--;
        }
        return s;
    }
}
